#ifndef DATE_H_INCLUDED
#define DATE_H_INCLUDED

class Date
{
public:
    // ctor
    Date(); // init 1970/1/1 THU
    Date(int y,int m, int d);

    // operator Mathed
    friend std::ostream& operator<<(std::ostream &os,const Date&);
    bool operator< (const Date& date)const  { return days < date.days;  }
    bool operator<=(const Date& date)const  { return days <= date.days; }
    bool operator> (const Date& date)const  { return !(*this <= date);  }
    bool operator>=(const Date& date)const  { return !(*this < date); }
    Date operator+(int n)const { return Date(days + n); }
    Date operator-(int n) const { return Date(days - n); }
    int operator-(const Date& date) const { return days - date.days; }
    Date& operator++()    { ++days; return *this; } //prefix ++

    Date  operator++(int) { Date ret(*this); ++(*this); return ret; } //postfix ++

private:
    int days;   // days from 1970/1/1
    Date(int d):days(d){}
    int calDays(int y,int m,int d) const;

    static bool leap(int year) { return (year%400==0)||(year%100!=0&&year%4==0); }
    static const std::string DWNames[7];
    static const std::string MNames[13];
    static const int Days_Month[2][13];
};

#endif // DATE_H_INCLUDED

